<template>
    <div style="font-size: 12px; line-height: 60px; display: flex;">
        <div style="flex: 1; ">
            <span :class="collapseBtnClass" style="cursor: pointer; font-size: 18px;" @click="collapse"></span>
        </div>
        <el-dropdown style="width: 100px; cursor: pointer;">
            <div>
                <img :src="user.avatarUrl" alt=""  style="width:30px; border-radius:50%;position: relative; top: 10px;right:5px;">
                <span>{{ user.nickname }}</span>
            <i class="el-icon-arrow-down" style="margin-left: 5px;"></i>
            </div>
            
            <el-dropdown-menu slot="dropdown">
                <el-dropdown-item><router-link style="text-decoration: none;" to="/person">个人信息</router-link></el-dropdown-item>
                <el-dropdown-item><router-link style="text-decoration: none;" to="/password">修改密码</router-link></el-dropdown-item>
                <el-dropdown-item>
                    <span style="text-decoration: none;" @click="logout">退出系统</span>
                </el-dropdown-item>
            </el-dropdown-menu>
        </el-dropdown>
    </div>
</template>

<script>
    export default {
        name: "Header",
        props: {
            collapseBtnClass: String,
            collapse: Boolean,
            pathName: String,
            user: Object,
        },
        data() {
            return {
                
            }
        },
        methods: {
            logout() {
                this.$router.push("/")
                localStorage.removeItem("user")
                this.$message.success("退出系统")

                // 重置路由
                resetRouter()
            }
        },
    }
</script>